package com.itheima.demo1exception;

import java.util.Scanner;

public class ExceptionDemo6 {

    public static void main(String[] args) {
        // 捕获异常对象，并尝试修复
        System.out.println("程序开始...");
        int num = 0;
        while (true) {
            try {
                num = test3();
                System.out.println(num);
                break;
            } catch (Exception e) {
                System.out.println("输入的价格出错");
            }
        }
        System.out.println("程序结束...");
    }

    public static int test3(){
        Scanner s = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int i = s.nextInt();
        return i;
    }
}
